﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Knlght.Domain
{
    public class ListResponse<T> : ResponseBase
    {
        public ListResponse(bool isSuccess = true, string error = "", int resultCode = -1) : base(isSuccess, error, resultCode)
        {
        }

        /// <summary>
        /// 获取到的回复对象集合
        /// </summary>
        public List<T> Models { get; set; }

        #region 辅助方法
        /// <summary>
        /// 创建 成功获取单个对象的回复对象
        /// </summary>
        public static ListResponse<T> CreateResponseBySuccess(List<T> models)
        {
            return new ListResponse<T>(true) { Models = models };
        }
        /// <summary>
        /// 获取操作失败的回复对象
        /// </summary>
        public static ListResponse<T> CreateResponseByFail(string error, int resultCode = ResultCodeConstants.NONE)
        {
            return new ListResponse<T>(false, error, resultCode);
        }
        #endregion
    }
}
